
import { get } from '../../http/axios'

export default {
    //命名空间  快速定位
    namespaced: true,
    //状态data  存储变量
    state: {
        art: {},
        category:{},
        datalist: {}
    },
    
    //突变  改变state中变量的唯一方式
    mutations: {
        set_art(state,val){
            state.art=val
        },
        set_category(state,val){
            state.category=val
        }
    },
    //动作 methods  存储方法  发送请求
    actions: {
        async page_query_art({commit}, params) {
            let res = await get('/article/pageQuery', params)
            // context.commit('set_datalist', res.data.data)
            //{commit}直接解构
            commit('set_art', res.data.data);
            // console.log(res);
            

        },
        async saveOrUpdate({commit},params){
            let res =await get ('/article/saveOrUpdate',params);
        },
        async findAllCategory({commit}){
            let res =await get ('/category/findAll');
            commit('set_category', res.data.data);
            // console.log(res);/


        }

    }
}